package com.demo2do.fms.admin.dao.supplier;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.demo2do.fms.entity.supplier.common.KeyPost;
import com.demo2do.fms.entity.supplier.common.SupplierBusinessHistory;
import com.demo2do.fms.entity.supplier.common.SupplierCertificate;
import com.demo2do.fms.entity.supplier.common.SupplierInfo;
import com.demo2do.fms.entity.supplier.common.SupplierParkingResource;
import com.demo2do.fms.entity.supplier.common.SupplierRecommendation;
import com.demo2do.fms.entity.supplier.common.SupplierStaff;
import com.demo2do.fms.entity.supplier.trans.TrailerType;
import com.demo2do.fms.entity.supplier.trans.TransSupplier;
import com.demo2do.fms.entity.supplier.trans.TransSupplierVehicleStat;
import com.demo2do.fms.entity.supplier.trans.VehicleType;
import com.demo2do.fms.entity.supplier.ware.WareSupplier;
import com.demo2do.fms.entity.supplier.ware.WareSupplierEmployee;

/**
 * 
 * @author Wy
 *
 */
@Dao("hibernate")
public interface SupplierProfileDao {
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM SupplierRecommendation s WHERE s.disabled = false AND s.supplier.id = :supplierId")
    public SupplierRecommendation getSupplierRecommendation(@Variable("supplierId") Long supplierId);
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM SupplierCertificate s WHERE s.disabled = false AND s.supplier.id = :supplierId")
    public SupplierCertificate getSupplierCertificate(@Variable("supplierId") Long supplierId);
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM SupplierInfo s WHERE s.disabled = false AND s.supplier.id = :supplierId")
    public SupplierInfo getSupplierInfo(@Variable("supplierId") Long supplierId);
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM SupplierBusinessHistory s WHERE s.disabled = false AND s.supplier.id = :supplierId")
    public List<SupplierBusinessHistory>  listSupplierBusinessHistory(@Variable("supplierId") Long supplierId);
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM SupplierParkingResource s WHERE s.disabled = false AND s.supplier.id = :supplierId")
    public List<SupplierParkingResource>  listSupplierParkingResource(@Variable("supplierId") Long supplierId);
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM SupplierStaff s WHERE s.disabled = false AND s.supplier.id = :supplierId")
    public List<SupplierStaff>  listSupplierStaff(@Variable("supplierId") Long supplierId);
    /**
     * 
     * @param supplierId
     * @param keyPost
     * @return
     */
    @Query("FROM SupplierStaff s WHERE s.disabled = false AND s.supplier.id = :supplierId AND s.keyPost = :keyPost")
    public SupplierStaff  getSupplierStaff(@Variable("supplierId") Long supplierId ,  @Variable("keyPost") KeyPost keyPost);
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM TransSupplierVehicleStat WHERE disabled = false AND supplier.id = :supplierId")
    public List<TransSupplierVehicleStat> listTransportVehicle(@Variable("supplierId") Long supplierId);
    
    /**
     * 
     * @param supplierId
     * @param vehicleType
     * @return
     */
    @Query("SELECT new com.demo2do.fms.entity.supplier.trans.TransSupplierVehicleStat(id,trailerType,propertyType,amount) FROM TransSupplierVehicleStat t WHERE t.disabled = false AND t.supplier.id = :supplierId AND t.vehicleType = :vehicleType ")
    public List<TransSupplierVehicleStat> listTransportVehicle(@Variable("supplierId") Long supplierId , @Variable("vehicleType") VehicleType vehicleType );
    
    /**
     * 
     * @param supplierId
     * @param vehicleType
     * @param trailerType
     * @return
     */
    @Query("SELECT new com.demo2do.fms.entity.supplier.trans.TransSupplierVehicleStat(id,trailerType,capacityType,amount) FROM TransSupplierVehicleStat t WHERE t.disabled = false AND t.supplier.id = :supplierId AND t.vehicleType = :vehicleType AND t.trailerType = :trailerType ")
    public List<TransSupplierVehicleStat> listTransportVehicle(@Variable("supplierId") Long supplierId , @Variable("vehicleType") VehicleType vehicleType , @Variable("trailerType") TrailerType trailerType);
    
    /**
     * @param supplierId
     * @param vehicleType
     * @param trailerType
     * @return
     */
    @Query("FROM TransSupplierVehicleStat WHERE disabled = false AND supplier.id = :supplierId AND vehicleType = :vehicleType AND trailerType = :trailerType")
    public TransSupplierVehicleStat getTransSupplierVehicleStat(@Variable("supplierId") Long supplierId, @Variable("vehicleType") VehicleType vehicleType, @Variable("trailerType") TrailerType trailerType);
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM TransSupplier t WHERE t.disabled = false AND t.supplier.id = :supplierId")
    public TransSupplier getTransSupplier(@Variable("supplierId") Long supplierId );
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM WareSupplier w WHERE w.disabled = false AND w.supplier.id = :supplierId")
    public WareSupplier getWareSupplier(@Variable("supplierId") Long supplierId );
    
    
    /**
     * 
     * @param supplierId
     * @return
     */
    @Query("FROM WareSupplierEmployee w WHERE w.disabled = false AND w.supplier.id = :supplierId ")
    public List<WareSupplierEmployee> listWareSupplierEmployee(@Variable("supplierId") Long supplierId);

    /**
     *
     * @param supplierId
     * @param keyPosts
     * @return
     */
    @Query("FROM SupplierStaff s WHERE s.disabled = false AND s.supplier.id = :supplierId AND s.keyPost IN (:keyPosts)")
    public List<SupplierStaff> listSupplierStaff(@Variable("supplierId") Long supplierId , @Variable("keyPosts") KeyPost[] keyPosts);

}
